﻿@using Software41.Tracking.Web.Infrastructure
@using Tracking = Software41.Tracking.Model;
@model IEnumerable<Tracking.ProcessTraceInfo>
    

<div id="SearchResults">
    <table id="tblSearchResults" class="searchResults tablesorter"">
        <thead>
            <tr>
                <th>Application</th>
                <th>Name</th>
                <th>Begin</th>
                <th>End</th>
                <th>Duration</th>
                <th>View</th>
            </tr>
        </thead>
        @foreach (Tracking.ProcessTraceInfo pi in Model)
        {
            <tr>
                <td>@Html.DisplayFor(m => pi.Application)</td>
                <td>@Html.DisplayFor(m => pi.Name)</td>
                <td>@(pi.Begin.HasValue == true ? pi.Begin.Value.ToLocalTime().ToString() : "")</td>
                <td>@(pi.End.HasValue == true ? pi.End.Value.ToLocalTime().ToString() : "")</td>
                <td>@Html.DisplayFor(m => pi.ProcessDuration)</td>
                <td>@Html.ActionLink("Details", "ProcessInfoDetails", new { processInfoActivityId = pi.ActivityID })
                </td>

            </tr>
        }
    </table>
    <div id="gridpager"></div>
</div>

@this.ScriptBlock(
    @<script type="text/javascript" src="@Url.Content("~/Scripts/i18n/grid.locale-en.js")"></script>)
@this.ScriptBlock(
    @<script type="text/javascript" src="@Url.Content("~/Scripts/jquery.jqGrid.src.js")"></script>)
@this.ScriptBlock(
    @<script type="text/javascript">
        $(document).ready(function () {
            // Convert the html table into a jqGrid.
            //tableToGrid(".searchResults",
            //    {
            //        pager: "#gridpager",
            //        height: "100%",
            //        hidegrid: true,
            //        autowidth: true
            //    });

            //// This fixes an issue where the paging initially shows 'page 1 of 0'.
            //$(".searchResults").setGridParam({ rowNum: 15 }).trigger("reloadGrid");
        })
    </script>)